package behavior.chain;

/**
 * @author dali
 * @date 2021-07-29 11:42
 * @Description 直系领导
 */

public class DirectHandler implements Handler{
    private Handler handler;

    @Override
    public void setNextHandler(Handler handler) {
        this.handler = handler;
    }

    @Override
    public boolean handler(int day) {
        if (day < 3) {
            System.out.println("直系领导批了");
            return true;
        }
        System.out.println("请假天数过长，交给上级领导审批...");
        //防止链条上错抛异常
        return handler == null ? false : handler.handler(day);
    }
}
